package com.relax.mybatis.encrypt.strategy.impl;

import com.relax.mybatis.constant.Algorithm;
import com.relax.mybatis.encrypt.algorithm.SM2;
import com.relax.mybatis.encrypt.strategy.EncryptStrategy;

/**
 * @author relax
 * @date 2022/07/05
 */
public class SM2EncryptStrategy implements EncryptStrategy {

    @Override
    public String encrypt(Algorithm algorithm, String password, String publicKey, String data) throws Exception {
        return SM2.encryptToBase64(data, publicKey);
    }

    @Override
    public String decrypt(Algorithm algorithm, String password, String privateKey, String data) throws Exception {
        return SM2.decryptFromBase64(data, privateKey);
    }

}
